from extensions import db


class _BaseModel(db.Model):
    """base model for flask-sqlalchemy"""

    __abstract__ = True

    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column(db.DateTime)
    updated_at = db.Column(db.DateTime)


class CRUDMixin:
    """minix class for models"""

    def save(self):
        db.session.add(self)
        db.session.commit()

    def delete(self):
        db.session.delete(self)
        db.session.commit()
